package com.example.demo.service.impl;

import com.example.demo.dataobject.BloodSugar;
import com.example.demo.repository.BloodSugarRepository;
import com.example.demo.service.BloodSugarService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Date;


@Service
@Slf4j
public class BloodSugarServiceImpl implements BloodSugarService {

    @Autowired
    private BloodSugarRepository bloodSugarRepository;

    @Override
    public BloodSugar save(Double bloodSugar, String telephone, Integer periodType, Date date, String remarks) {

        if(StringUtils.isEmpty(telephone)||bloodSugar==null){
            log.info("电话号码或者血糖数值为空");
            return null;
        }
        BloodSugar sugar = new BloodSugar( bloodSugar,telephone,periodType,date,remarks);
        BloodSugar result = bloodSugarRepository.save(sugar);

        return result;


    }
}
